cmake_minimum_required(VERSION 3.10)

ENABLE_LANGUAGE(ASM)
#add_definitions(-D __ARM_NEON)
add_definitions(-D PLATFORM_LINUX)
add_definitions(-D ARC_DCIRDLL_EXPORTS)

unset(NCNN_OPENMP		CACHE)
unset(USE_SHRED_LIBRARY		CACHE)

option(NCNN_OPENMP       	"openmp support" 					ON)
option(USE_SHRED_LIBRARY 	"Set to switch to use bokeh shared library " 		OFF)

#message(STATUS "ANDROID_TOOLCHAIN  ${ANDROID_TOOLCHAIN}")
message(STATUS "CMAKE_CXX_COMPILER_ID  ${CMAKE_CXX_COMPILER_ID}")

# using GCC
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffunction-sections -fdata-sections -fno-gnu-unique -fvisibility=hidden -fuse-ld=gold")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffunction-sections -fdata-sections -fno-gnu-unique -fvisibility=hidden -fuse-ld=gold")
message(STATUS "CMAKE_SHARED_LINKER_FLAGS  ${CMAKE_SHARED_LINKER_FLAGS}")

if(NCNN_OPENMP)
	SET ( CMAKE_CXX_FLAGS "-fopenmp ${CMAKE_CXX_FLAGS}" )
	#SET ( GOMP_CPU_AFFINITY "4 5 6 7") //for test
endif()

message(STATUS "CMAKE_CXX_FLAGS_RELEASE  ${CMAKE_CXX_FLAGS_RELEASE}")

configure_file (
  "${CMAKE_SOURCE_DIR}/src/native_debug.h.in"
  "${CMAKE_SOURCE_DIR}/src/native_debug.h"
  )

if (PERFORMANCE_ANALYSIS)
	add_definitions(-DPERFORMANCE_ANALYSIS)
endif()

SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/libs/)
# ###################### native library ###########################

set(CXX_INC_PATH  ${CMAKE_SOURCE_DIR}/src)
include_directories(${CXX_INC_PATH})
include_directories(${CXX_INC_PATH}/eigen-3.3.7)


set( CXX_SRC_PATH ${CMAKE_CURRENT_LIST_DIR} )

add_library(tcl_dualcam_image_depth
		SHARED
		${CXX_SRC_PATH}/TCLStereoDepthAlg.cpp
		${CXX_SRC_PATH}/TCLStereoDepthAlgUtils.cpp
		)

# for static compile
target_link_libraries(
		tcl_dualcam_image_depth

		-Wl,--whole-archive
		${MNN_LIB_PATH}
		-Wl,--no-whole-archive

		${OpenCV_LIBRARIES}
		${VISION_ENGINE_PATH}
		)

# for dynamic compile
# target_link_libraries(
# 		tcl_dualcam_image_depth
# 		${OpenCV_LIBRARIES}
# 		${VISION_ENGINE_PATH}
# 		)

############OpenMP支持####################################
#[[if(NCNN_OPENMP)
    find_package(OpenMP)
    if(NOT TARGET OpenMP::OpenMP_CXX AND (OpenMP_CXX_FOUND OR OPENMP_FOUND))
        target_compile_options(arcsoft_dualcam_refocus_image PRIVATE ${OpenMP_CXX_FLAGS})
        #target_compile_options(arcsoft_dualcam_refocus_image_bokeh PRIVATE ${OpenMP_CXX_FLAGS})
		#target_compile_options(arcsoft_dualcam_refocus_image_depth PRIVATE ${OpenMP_CXX_FLAGS})
    endif()
endif()]]
